<%@ page contentType="text/html;charset=UTF-8" language="java" %>

<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<table class="display" id="example">
	<thead>
		<tr>
			<th>选择</th>
			<th><strong>员工工号</strong></th>
			<th><strong>姓名</strong></th>
			<th><strong>部门</strong></th>
			<th><strong>职务</strong></th>
			<th><strong>本月上班天数</strong></th>
			<th><strong>实际上班天数</strong></th>
			<th><strong>底薪</strong></th>
		</tr>
	</thead>
	<tbody>
		<s:if test="#request.attendances == null || #request.attendances.size() <= 0">
			<tr class="gradeX"> <td colspan="8">暂无数据</td> </tr>
		</s:if>
		<s:else>
			<s:iterator value="#request.attendances" var="a" status="sta">
				<s:if test="#sta.even"> <tr class="gradeA"> </s:if> <s:else> <tr class="gradeC"> </s:else>
				<td><input type="checkbox" name="chk_base_salary" value="${w.id}" /></td>
				<td>${a.employeeinfoWork.workNo}</td>
				<td>${a.employeeinfoWork.baseId.name}</td>
				<td>${a.employeeinfoWork.organization.fullName}</td>
				<td>${a.employeeinfoWork.duty.dutyName}</td>
				<td>${a.washDays}</td>
				<td>${a.workDays}</td>
				<td>${a.employeeinfoWork.gradeLevel.gradePay}</td>
				</tr>
			</s:iterator>
		</s:else>
	</tbody>
</table>
<p id="${listType}" class="ehr">
    <%@ include file="/WEB-INF/pages/common/main_orgtab_pager.jsp"%>
</p>
<script type="text/javascript">
    function searchClickEvent(){
        var year = $("#search_year").prev("span").html(); //2012年
        year = year.substr(0, year.length - 1); //2012
        var month = $("#search_month").prev("span").html(); //2月
        month = month.substr(0, month.length - 1); //2
        var lastOrgSelectionName = $("#org_sel_1").find("select:last").prev("span").html(); //最后一个部门select选中的项名
        var lastOrgSelectOptions = $("#org_sel_1").find("select:last").find("option"); //最后一个部门select的option列表
        //alert(lastOrgSelectOptions.length)
        //alert(lastOrgSelectionName)
        var selectionOrgId = 0;
        for(var i=0; i<lastOrgSelectOptions.length;i++){
            var opt = lastOrgSelectOptions[i];
            if($(opt).html() == lastOrgSelectionName){
                //alert("选中的部门ID:"+$(opt).val());
                selectionOrgId = $(opt).val();
                break;
            }
        }
        if($("#org_sel_1").find("select").length > 1){
            //如果最后一个部门没有选择，则查找其上一部门所有
            if(selectionOrgId == 0 || selectionOrgId == "-1"){
                var tempId = $("#org_sel_1").find("select:last").parent("div").attr("id"); //uniform-undefined-4
                selectionOrgId = tempId.substr("uniform-undefined-".length, tempId.length);
            }
        }


        var dutySelectionName = $("#duty_sel_1").prev("span").html();
        var dutySelectOptions = $("#duty_sel_1").find("option");
        var selectionDutyId = 0;
        for(var i=0; i<dutySelectOptions.length;i++){
            var opt = dutySelectOptions[i];
            if($(opt).html() == dutySelectionName){
                //alert("选中的职务ID:"+$(opt).val());
                selectionDutyId = $(opt).val();
                break;
            }
        }


        var data = {
            "year":year,
            "month":month,
            "selectionOrgId":selectionOrgId,
            "selectionDutyId":selectionDutyId,
            "organizationId":"${organizationId}"
        }
        var url = "${ctx}/salary/base_salary_list.xhtml";
        $.ajax(url, {
            type: "POST",
            data: data,
            dataType:"html",
            cache:false,
            success:function(a) {
                $("#list_content_${organizationId}").html(a);
            },
            complete:function() {}
        });
    }
</script>